﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
namespace _16._02._13
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
        private string GetPublicIp()//айпи в инете
        {
          
            WebRequest wr = WebRequest.Create("http://checkip.dyndns.org/");
            WebResponse wr2 = wr.GetResponse();
            StreamReader sr  = new StreamReader(wr2.GetResponseStream());
            string IPpage = sr.ReadToEnd();
            int start = IPpage.IndexOf("s: ")+3;
            int finish = IPpage.LastIndexOf("</body>");
            return IPpage.Substring(start,finish - start);

        }


     

        private void btn1_Click(object sender, EventArgs e)
        {
            tb1.Text = Dns.GetHostName();//имя локалки
          
            tb3.Text = GetPublicIp();//айпи в инете(вызов функции)
           
        }

    }
}
